package pits.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import pits.form.DeleteTakenProjectForm;

public class DeleteTakenProjectDAO {

	public void update(DeleteTakenProjectForm formDeleteTakenProject) {
		Connection connection = null;
		String query = null;
		PreparedStatement sqlStatement = null;

		try {
			connection = pits.util.Connection.getConnection();

			for (int i = 0; i < formDeleteTakenProject.getProjectIDs().size(); i++) {
				query = "DELETE FROM projectexp " + "WHERE EmpID=" + formDeleteTakenProject.getEmpID() + " "
				        + "AND ProjectID=" + formDeleteTakenProject.getProjectIDs().get(i);

				// new pits.util.Logger().writeln(query);

				sqlStatement = connection.prepareStatement(query);
				sqlStatement.executeUpdate();
			}
		} catch (Exception sqlEx) {
			new pits.util.Logger().writeln(sqlEx.toString());
		} finally {
			try {
				sqlStatement.close();
				connection.close();
			} catch (SQLException sqlEx) {
				new pits.util.Logger().writeln(sqlEx.toString());
			}
		}
	}
}
